package com.apes.enquiry.enquiry.model;

import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import java.util.Date;

/**
 * 类描述：报价单
 *
 * @ClassName Quote
 * @Description 描述
 * @Author wushilong
 * @Date 2023/3/16 9:13
 * @Version 1.0
 */


@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = Quote.CONST_TABLE_NAME, indexes = {@Index(columnList = "enquiry_id, party_role_id", unique = true)})
public class Quote extends Model {

    public static final String CONST_TABLE_NAME = "sp_mas_quote";

    @Id
    @Column(name = "id", length = 10)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "报价单", prefix = "BJ", padding = 8)
    @Comment("编码")
    private String id; //报价单号

    @Column(name = "enquiry_id", length = 32, nullable = false)
    @Comment("询价单号")
    private String enquiryId;

    @Column(name = "party_role_id", length = 32, nullable = false)
    @Comment("供应商id")
    private String partyRoleId;

    @Column(name = "model_id", length = 32)
    @Comment("巴图鲁询价单号")
    private String modelId;

    @Column(name = "error_message", length = 500)
    @Comment("巴图鲁询价错误信息")
    private String errorMessage;

    @Column(name = "first_quote_date")
    @Comment("巴图鲁首次报价时间")
    private Date firstQuoteDate;

    @Column(name = "update_quote_date")
    @Comment("巴图鲁报价修改时间")
    private Date updateQuoteDate;

    @Column(name = "state", length = 32)
    @Comment("状态")
    private String state;//ing(报价中), finish(完成), expired(过期)
}
